
/*
防拆报警
*/

#include "BSP_Switch.h"
#include "Timer.h"
#include "Door.h"

#include "Env.h"

static Timer_T switchTimer;
static int8_t switchState;

static void SwitchCallback(void){	
	if(envProp.workMode == DEV_M_Reader){
		return;
	}
	int sig = BSP_Switch_Signal();

	switch(switchState){
	case 0:{
		if(sig){
			Door_Unlock(envProp.devParams.openDoorTime);
			//switchState = 1;
		}
	}
	break;
	case 1:{
		if(!sig){
			switchState = 0;
		}
	}
	break;
	}
}

/*
初始化出门开关
*/
void Switch_Init(void){
	switchState = 0;
	Timer_Setup(&switchTimer, 10, 1, 0, SwitchCallback);
	Timer_Restart(&switchTimer);
}





